package cn.huolabao.controller;

import cn.huolabao.common.core.utils.R;
import cn.huolabao.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/portal")
@Slf4j
@RequiredArgsConstructor
@Api(tags = "用户信息前端数据")
public class UserPortalController {

    private final SysUserService userService;
    @RequestMapping("/info")
    @ApiOperation(value = "获取用户详情", httpMethod = "GET")
    public R info() {
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        return R.ok(userService.getUserPortalInfo(username));
    }

    @RequestMapping("/nav")
    @ApiOperation(value = "获取用户菜单", httpMethod = "GET")
    public R nav() {
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        return R.ok(userService.getUserPortalNav(username));
    }


}
